{% load static %}
{% load manager_category_tags %}
{% load manager_user_tags %}
{% load utils %}
<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <title>添加内容</title>
    <link rel="stylesheet" href="{% static '/public/css/ui.css' %}">
    <link rel="stylesheet" href="{% static '/public/select/select.css' %}">
    <link rel="stylesheet" href="{% static '/public/admin/css/layout.css' %}">
    <script>var api_url = "/manager/upload/imagelist/?type=3&multiple=1";</script>
    <script src="{% static 'public/js/jquery.js' %}"></script>
    <script src="{% static 'public/js/ui.js' %}"></script>
    <script src="{% static 'public/select/select.js' %}"></script>
    <script src="{% static 'public/js/dropzone.js' %}"></script>
    <script src="{% static 'public/js/sortable.min.js' %}"></script>
    <script src="{% static '/public/tinymce/tinymce.min.js' %}"></script>
    <script src="{% static 'public/admin/js/base.js' %}"></script>
</head>

<body>

    <div class="position">当前位置：<a href="/manager/content/lists">内容管理</a>{% if classid > 0 %}{{classid|get_page_postion|safe}}{% endif %}</div>
    <div class="borders">
        <!---->
        <form class="ui-form" method="post">
            <div class="ui-tabs ui-tabs-white">
                <ul class="ui-tabs-nav">
                    <li class="active"><a href="javascript:void(0)">基本设置</a></li>
                </ul>
                <div class="ui-tabs-content">
                    <div class="ui-tabs-pane active">
                        <div class="ui-form-group ui-row">
                            <label class="col-left ui-col-form-label">标题：</label>
                            <div class="col-right">
                                <input type="text" name="title" id="title" class="ui-form-ip" maxlength="255" value=""
                                    data-rule="标题:required;">
                            </div>
                        </div>
                        <div class="ui-form-group ui-row">
                            <label class="col-left ui-col-form-label">关键字：</label>
                            <div class="col-right-full">
                                <input type="text" name="key" id="key" class="ui-form-ip" maxlength="255" value=""
                                data-rule="关键字:required;">
                            </div>
                        </div>
                        <div class="ui-form-group ui-row">
                            <label class="col-left ui-col-form-label">正文：</label>
                            <div class="col-right-full">
                                <textarea id="content" name="content" class="tinymce-textarea" ></textarea> 
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="ui-form-group ui-mt">
                {% csrf_token %}
                <button type="submit" class="ui-btn ui-btn-info ui-mr-sm">保存</button>
                <button type="button" class="ui-btn ui-back">返回</button>
            </div>
        </form>
        <!---->
    </div>
    <script src="{% static '/public/datepick/laydate.js' %}"></script>
    <script src="{% static '/public/admin/js/tinymce_auto.js' %}"></script>
    <script>
        $(function () {

            $('.selectbox').SumoSelect(
                {
                    csvDispCount: 4,
                    captionFormat: '已选择：{0} 个',
                });

            lay('.datepick').each(function () {
                laydate.render(
                    {
                        elem: this,
                        trigger: 'click'
                    });
            });
            lay('.datepick-time').each(function () {
                laydate.render(
                    {
                        elem: this,
                        type: 'datetime',
                        trigger: 'click'
                    });
            });
            $(".ui-form").form(
                {
                    type: 2,
                    result: function (form) {
                        $.ajax(
                            {
                                type: 'post',
                                cache: false,
                                dataType: 'json',
                                url: '/manager/block/add/',
                                data: $(form).serialize(),
                                error: function (e) { alert(e.responseText); },
                                success: function (d) {
                                    if (d.state == 'success') {
                                        wmcms.success(d.msg);
                                        setTimeout(function () { location.href = '/manager/block/index'; }, 1500);
                                    }
                                    else {
                                        wmcms.error(d.msg);
                                    }
                                }
                            });
                    }
                });
        })
    </script>
</body>
</html>